package com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.controller;


import com.alibaba.fastjson.JSONObject;
import com.fufan.mtsaas.modules.common.bo.request.DataRequest;
import com.fufan.mtsaas.modules.common.bo.request.DataRequestT;
import com.fufan.mtsaas.modules.common.bo.request.ResultPack;
import com.fufan.mtsaas.modules.common.bo.response.RequestPojo;
import com.fufan.mtsaas.modules.common.bo.response.Result;
import com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.bo.request.XjsReviewLimitTechDocQueryRequest;
import com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.bo.request.XjsReviewLimitTechDocSaveRequest;
import com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.bo.response.XjsReviewLimitTechDocResponse;
import com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.model.XjsReviewLimitTechDoc;
import com.fufan.mtsaas.modules.newtech.xjsreviewlimittechdoc.service.XjsReviewLimitTechDocSvc;
import com.fufan.mtsaas.util.JSonUtil;
import com.fufan.mtsaas.util.ParamUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 * 年度限制类人员档案表
 * </p>
 *
 * @author Liby
 * @since 2025-02-14
 */
@Api(tags = "新技术-年度限制类人员档案表")
@RestController
@RequestMapping("/MTSaas/xjsReviewLimitTechDoc")
@Slf4j
public class XjsReviewLimitTechDocCtrl {
    @Autowired
    private XjsReviewLimitTechDocSvc targetService;

    /**
     * 分页查询
     */
    @ApiOperation(value = "分页查询所有，根据需要传入分页参数：pageSize每页数量(默认为10)，currentPage当前页数(默认为1)", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/doQueryPage")
    public Result<XjsReviewLimitTechDocResponse> doQueryPage(@RequestBody @ApiIgnore DataRequest dataRequest, XjsReviewLimitTechDocQueryRequest request) {
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();

        JSONObject mapdata = dataRequest.getData().getParam();
        XjsReviewLimitTechDocQueryRequest map = JSonUtil.toBean(mapdata.toJSONString(), XjsReviewLimitTechDocQueryRequest.class);

        return resultPack.doResultPack(targetService.doQueryPage(map), requestPojo.getIntfId(), requestPojo.getAppKey());
    }

    /**
     * 新增
     */
    @ApiOperation(value = "新增", httpMethod = "POST", produces = "application/json")
    @RequestMapping(value = "/doSave", method = RequestMethod.POST)
    public Result<XjsReviewLimitTechDocResponse> doSaveMap(@RequestBody @ApiIgnore @Valid DataRequestT<XjsReviewLimitTechDocSaveRequest> dataRequest, XjsReviewLimitTechDocSaveRequest request, @ApiIgnore HttpSession session) {
        log.debug("doSave parameter: {}", dataRequest);

        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();

        return resultPack.doResultPack(targetService.doSave(dataRequest.getData().getParam(), requestPojo), requestPojo.getIntfId(), requestPojo.getAppKey());
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", produces = "application/json")
    @RequestMapping(value = "/doUpdate", method = RequestMethod.PUT)
    public Result<XjsReviewLimitTechDocResponse> doUpdateMap(@RequestBody @ApiIgnore @Valid DataRequestT<XjsReviewLimitTechDocSaveRequest> dataRequest, XjsReviewLimitTechDocSaveRequest request, @ApiIgnore HttpSession session) {
        log.debug("doUpdate parameter: {}", dataRequest);

        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();

        return resultPack.doResultPack(targetService.doUpdate(dataRequest.getData().getParam(), requestPojo), requestPojo.getIntfId(), requestPojo.getAppKey());
    }

    /**
     * 删除数据
     */
    @ApiOperation(value = "删除数据", httpMethod = "DELETE", produces = "application/json")
    @RequestMapping(value = "/doDelete", method = RequestMethod.DELETE)
    public Result doDelete(@RequestBody @ApiIgnore DataRequest dataRequest, XjsReviewLimitTechDocQueryRequest request) {
        log.debug("doDelete parameter: {}", dataRequest);

        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        JSONObject mapdata = dataRequest.getData().getParam();
        XjsReviewLimitTechDocQueryRequest map = JSonUtil.toBean(mapdata.toJSONString(), XjsReviewLimitTechDocQueryRequest.class);

        return resultPack.doResultPack(targetService.doDelete(map, requestPojo), requestPojo.getIntfId(), requestPojo.getAppKey());
    }


}
